package gregorytersoff_model;

public class Line 
{
	private String choice;
	private int position;
	
	/**
	 * Line stores the name and starting position of each line. While it is associated with a line drawn by the LineCanvas and the JTextField
	 * generated above that line by the DecisionlinesGUI, it is not actually created until each name has been locked in
	 * @param name The string indicating which choice name is associated with this line
	 * @param place The relative position of the line
	 */
	public Line(String name, int place)
	{
		choice = name;
		position = place;
	}
	/**
	 * gives access to the name of the choice associated with this line
	 * @return the name of the choice associated with this line
	 */
	public String getChoice()
	{
		return choice;
	}
	/**
	 * Traces the path beginning at the top of this line by going through each height and checking if there is an edge there connected to the
	 * current position, with each check using as input the result of the last check as its current position
	 * @param edges the array of edges 
	 * @param height the starting height, a carryover from when this method was going to be recursively called by the model, and left in to avoid
	 * breaking the program at the last minute
	 * @return the final position of the traced path starting at the top of this line
	 */
	public int solveYourself(Edge[] edges, int height)
	{
		for(int i = height; i < 64; i++)
		{
			if(edges[i] != null)
			{
				position = edges[i].checkLines(position);
			}
		}
		return position;
	}
}
